#include <iostream>
#include <vector>

using namespace std;

class Solution {
public:
    int rob(vector<int>& nums) {
        if (nums.size() == 0) {
            return 0;
        }
        vector<vector<int>> profit(2, vector<int>(2, 0));
        profit[1][1] = nums[0];
        for (int i = 1; i < nums.size() - 1; i++) {
            int n1, n2, n3, n4;
            n3 = max(profit[0][0] + nums[i], profit[1][0]);
            n4 = max(profit[0][1] + nums[i], profit[1][1]);
            n1 = max(profit[0][0], profit[1][0]);
            n2 = max(profit[0][1], profit[1][1]);
            profit[0][0] = n1;
            profit[0][1] = n2;
            profit[1][0] = n3;
            profit[1][1] = n4;
        }
        profit[1][0] = max(profit[1][0], profit[0][0] + nums.back());
        return max(max(profit[1][0], profit[1][1]), max(profit[0][1], profit[0][0]));
    }
};

int main() {
    vector<int> input = {2, 3, 2};
    Solution solution;
    int output = solution.rob(input);
    cout << output << endl;
    return 0;
}